package i_introduction._10_Object_Expressions

import util.TODO
import util.doc10
import java.util.*

fun todoTask10(): Nothing = TODO(
        """
        Task 10.
        Read about object expressions that play the same role in Kotlin as anonymous classes do in Java.

        Add an object expression that provides a comparator to sort a list in a descending order using java.util.Collections class.
        In Kotlin you use Kotlin library extensions instead of java.util.Collections,
        but this example is still a good demonstration of mixing Kotlin and Java code.
    """,
        documentation = doc10()
)

//assertEquals(listOf(5, 2, 1), task10())
fun task10(): List<Int> {
    val arrayList = arrayListOf(1, 5, 2)
//    Collections.sort(arrayList, todoTask10())
    Collections.sort(arrayList, kotlin.Comparator { o1, o2 -> o2 - o1 })
    return arrayList
}